package com.goods.business.converter;

import com.goods.common.model.business.Product;
import com.goods.common.vo.business.ProductVO;
import org.springframework.beans.BeanUtils;
import org.springframework.stereotype.Component;
import org.springframework.util.CollectionUtils;

import java.util.ArrayList;
import java.util.List;

@Component
public class ProductConverter {
    public List<ProductVO> ProductVOList(List<Product> ProductList) {
        List<ProductVO> ProductVOS = new ArrayList<>();
        if (!CollectionUtils.isEmpty(ProductList)) {
            for (Product Product : ProductList) {
                ProductVO ProductVO = convertProductVO(Product);
                ProductVOS.add(ProductVO);
            }
        }

        return ProductVOS;


    }

    private ProductVO convertProductVO(Product Product) {
        ProductVO ProductVO = new ProductVO();
        BeanUtils.copyProperties(Product, ProductVO);
        return ProductVO;
    }
}
